//*************************************************************************//
//*           _____   ____________            ______               __     *//
//*          / /__ \ / ____/ ____/           / ____/___  _________/ /     *//
//*     __  / /__/ // __/ / __/    ______   / /_  / __ \/ ___/ __  /      *//
//*    / /_/ // __// /___/ /___   /_____/  / __/ / /_/ / /  / /_/ /       *//
//*    \____//____/_____/_____/           /_/    \____/_/   \__,_/        *//
//*                                                                       *//
//*     Copyright (c) 2006 Ford Argentina. All Rights Reserved.           *//
//*                                                                       *//
//*************************************************************************//

package ar.com.ford.it.webengine.security.jstl.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

public class RestrictedBlockTag extends BodyTagSupport {

	protected String authorizedFor; 
	protected String relation;

	public int doStartTag() throws JspException {	
					
		if(TagUtils.getInstance().isAuthorized(pageContext, this.authorizedFor, this.relation))				
			return EVAL_BODY_INCLUDE;
						
		return SKIP_BODY;
									
	}

	public int doEndTag() throws JspException {
		this.release();
		return EVAL_PAGE;
	}	
	
	
	public void release() {
		super.release();
		this.authorizedFor = null;
		this.relation = null;
	}

	public String getAuthorizedFor() {
		return authorizedFor;
	}
	
	public void setAuthorizedFor(String authorizedFor) {
		this.authorizedFor = authorizedFor;
	}
	
	public String getRelation() {
		return relation;
	}
	
	public void setRelation(String relation) {
		this.relation = relation;
	}

}
